﻿// JScript 文件

//----------------------经营分析图形显示类------------------------
/////////////////////////////////////////////////////////////////////////////

function CtnEconMap(mapObj)
{
    this.divMap = null;
    this.mapObj = mapObj;
    this.RegList = new Array();
    this.month = null;
    this.type = null;
    this.grade = null;
    
    
     //地图管线实体容器
    this.CreateDivMap = function()
    {
        this.divMap = document.createElement("div");
        
        this.divMap.style.position = "absolute"
        this.divMap.style.visibility = "visible"
       
        this.divMap.style.left = "0px"
	    this.divMap.style.top = "0px"
	    this.divMap.style.zIndex = 1
        this.divMap.id = "divecon"
        document.getElementsByTagName('BODY')[0].appendChild(this.divMap)
    }
    
    this.DrawQlqy = DrawQlqy_Ec;
    this.SetPara = SetPara_Ec;
}

function SetPara_Ec(month, type, grade)
{
    this.month = month;
    this.type = type;
    this.grade = grade;
}

function DrawQlqy_Ec()
{
    var TwoXy = "";
    var bodyWidth = 0;
    var bodyHeight = 0;
    if(CtnBrowser.IE)
    {
        bodyWidth  = window.$body.clientWidth;
        bodyHeight  = document.documentElement.clientHeight;
    }
    else if(CtnBrowser.FF)
    {
        bodyWidth  = document.documentElement.clientWidth;
        bodyHeight  = document.documentElement.clientHeight;
    }
	    
    var logicMin = logicCoordinate(0,parseInt(bodyHeight),this.mapObj);
  	var logicMax = logicCoordinate(parseInt(bodyWidth),0,this.mapObj);
	var xmin = logicMin[0];
	var ymin = logicMin[1];
	var xmax = logicMax[0];
	var ymax = logicMax[1];
	var TwoXy = xmin + "," + ymin + "@" + xmax + "," + ymax;
	
	
                   //测试构造数据
                  /*var vX = xmin + (xmax - xmin)/5;
                   var vY = ymin + (ymax - ymin)/5;
                   var tmpDot = new D_Dot2D(parseInt(vX),parseInt(vY),true);
                   var tmpDotList = new Array();
                   tmpDotList.push(tmpDot);
                   
                   vX = xmax - (xmax - xmin)/5;
                   vY = ymax - (ymax - ymin)/5;
                   tmpDot = new D_Dot2D(parseInt(vX),parseInt(vY),true);
                   tmpDotList.push(tmpDot);
                   
                   vX = xmin + (xmax - xmin)/5;
                   vY = ymax - (ymax - ymin)/5;
                   tmpDot = new D_Dot2D(parseInt(vX),parseInt(vY),true);
                   tmpDotList.push(tmpDot);
                   
                   vX = xmax - (xmax - xmin)/5;
                   vY = ymin + (ymax - ymin)/5;
                   tmpDot = new D_Dot2D(parseInt(vX),parseInt(vY),true);
                   tmpDotList.push(tmpDot);
                   
                   vX = xmin + (xmax - xmin)/5;
                   vY = ymin + (ymax - ymin)/5;
                   tmpDot = new D_Dot2D(parseInt(vX),parseInt(vY),true);
                   tmpDotList.push(tmpDot);
                  
                  this.RegList = new Array();
                   this.RegList.push(tmpDotList);*/
             
           
     //获取新的要显示的信息
     var vXmlVal = top.CtnTrans.getText("/main.ashx?", "post", "_method=GetShowInfoByXy&TwoXy="+escape(TwoXy) + "&month="+escape(this.month) + "&type=" + escape(this.type) + "&grade="  + escape(this.grade)); 
     if (!top.CtnError.validate(vXmlVal))
     {
         top.CtnError.show();
         return;
     }
     else
     {
        this.RegList = new Array();
        var qyArr    = new Array();
        var qyColor  = new Array();
        var qyName   = new Array();
        var showStr  = new Array();
        if(vXmlVal.indexOf("-") > 0 )//有多个区域
        { 
            qyArr = vXmlVal.split("-");
            qyColor.length = qyName.length = showStr.length = qyArr.length;
        }
        else//只有一个区域
        {
            qyColor.length = qyName.length = showStr.length = qyArr.length = 1;
            qyArr[0] = vXmlVal;
        }
        for(var m=0; m < qyArr.length; m++)
        {
            var allDots = qyArr[m].split("@")[0].split(";");
            var vX = 0;
            var vY = 0;
            var tmpDotList = new Array();
            qyColor[m] = qyArr[m].split("@")[1];
            qyName[m]  = qyArr[m].split("@")[2];
            showStr[m] = qyArr[m].split("@")[3];
            for (var i = 0; i<allDots.length;i++)
            {
                vX = allDots[i].split(",")[0];
                vY = allDots[i].split(",")[1];
                var tmpDot = new D_Dot2D(parseInt(vX),parseInt(vY),true);
                tmpDotList.push(tmpDot);
            }
            this.RegList.push(tmpDotList);
        } 
         
        var num = 0;
        for(var i = $("allInfoDiv").length - 1; i >= 0 ;i--)
        {
            $("allInfoDiv").removeChild($("allInfoDiv").childNodes[i])
        }
        $("allInfoDiv").innerHTML = "";
        for(var i = 0; i < this.RegList.length; i++)
        {
            arg = { id:"reg" + i + "_vml", 
                    name:"reg" + i + "_vml", 
                    zIndex: "12",
                    classStyle:" ",
                    strokeweight: "3px", 
                    strokecolor: "red", 
                    stroked: false,
                    filled:true,
                    fillcolor:qyColor[i],
                    OnMouseOver: null,
                    onmouseClick: null,
                    Content: qyName[i] + "," + showStr[i],
                    dotArr: this.RegList[i]
                 }
            var regvml = new PolyLineShape(arg);
            regvml.Draw();
        } 
    }  
}   